<?php

class Application_Model_DbTable_WayLog extends Application_Model_DbTable_DomainObject{
    
    protected $_name = 'uuch_wayLog';
    
    public function getMapper() {
        return array('id','wayId','description','dateCreated','operator',"operateType","type");
    }
    
    public function getCountByTypeOperator($operateType,$nikeName,$type,$startDate,$endDate)
    {
        $db = $this->getAdapter();
        $sql = "SELECT count(*) as num FROM uuch_wayLog as wl JOIN uuch_waybill as wb ON wl.wayId = wb.id ";
        $sql.= $db->quoteInto(" and wb.dateSend >= ?", $startDate." 00:00:00");
        $sql.= $db->quoteInto(" and wb.dateSend <= ?", $endDate." 23:59:59");
        $sql.= $db->quoteInto(" where wl.type = ?", $type);
        $sql.= $db->quoteInto(" and wl.operateType = ?", $operateType);
        if($nikeName != ""){
            $sql.= $db->quoteInto(" and wl.operator = ?", $nikeName);
        }
        $row = $db->fetchRow($sql);
        return $row["num"];
    }
}